/// Qualab - 24/11/2011

#pragma once

#include <wink/types.h>
#include <vector>

namespace wink
{
    class WindowData;

    class Window
    {
    public:
        Window( void* at = NULL );
        Window( PString text, void* at = NULL );
        Window( PString text, int width, int height, void* at = NULL );
        Window( PString text, int x, int y, int width, int height, void* at = NULL );
        Window( PString text, int x, int y, int width, int height, int show_mode, void* at = NULL );
        Window( const Window& source, bool clone = false, void* at = NULL );
        Window( HWND handle, void* at = 0 );

        virtual ~Window();

        bool IsSet() const;
        bool IsNotSet() const;
        void AssertIsSet() const;
        bool IsOwnData() const;

        Window& operator = ( const Window& source );

        void Create( PString text, void* at = NULL );
        void Create( PString text, int width, int height, void* at = NULL );
        void Create( PString text, int x, int y, int width, int height, void* at = NULL );
        void Create( PString text, int x, int y, int width, int height, int show_mode, void* at = NULL );

        void Close();

        void Reset( void* at = NULL );
        void Reset( HWND handle, void* at = NULL );
        void Reset( const Window& source, bool clone = false, void* at = NULL );

        operator HWND () const;

        HWND Handle() const;

        bool operator == ( const Window& other ) const;
        bool operator != ( const Window& other ) const;

        int Left() const;
        int Top() const;
        int Right() const;
        int Bottom() const;

        int Width() const;
        int Height() const;

        int ClientWidth() const;
        int ClientHeight() const;

        void UpdateRect();

        const Rect& Shape() const;
        const Rect& Client() const;

        typedef int  (*OnMoveProc)( Window& );
        typedef int  (*OnResizeProc)( Window& );
        typedef int  (*OnMouseLDownProc)( Window&, int x, int y );
        typedef int  (*OnMouseLUpProc)( Window&, int x, int y );
        typedef void (*OnCloseProc)( Window& );

        void       SetOnMove( OnMoveProc proc );
        void     SetOnResize( OnResizeProc proc );
        void SetOnMouseLDown( OnMouseLDownProc proc );
        void   SetOnMouseLUp( OnMouseLUpProc proc );
        void      SetOnClose( OnCloseProc proc );

        int  OnMove();
        int  OnResize();
        int  OnMouseLDown( int x, int y );
        int  OnMouseLUp( int x, int y );
        void OnClose();

    private:
        WindowData*         mData;
        std::vector< Byte > mBlock;
    };
}
